//index.js
//获取应用实例
const app = getApp()
const Api = require("../../utils/api.js").API
// const Store = require("../../utils/store.js").store
const codeZ = require("../../utils/util.js")
Page({ 
    data: {
        hei2:500,
        list: [],
        page: 1,
        limit: 10,
        Serchvalue: ''
    },
    onShow(){
        this.setData({
             hei2:app.globalData.screenHeight-60
        })
        this.initParam()
        this.getShopKeeper()
    },
    jump(event) {
        let item = event.currentTarget.dataset.item
        wx.navigateTo({
            url: '../shopDetail/index',
            success: function(res) {
                // 通过eventChannel向被打开页面传送数据
                res.eventChannel.emit('acceptDataFromOpenerPage', { data:item,type:'111801'})
            }
        })
    },
    onSureSearch() {
        this.initParam()
        this.getShopKeeper()
    },
    initParam() {
        this.setData({
            page: 1,
            list: []
        })
    },
    onSerach(event) {
        let _this = this;
        this.setData({
            Serchvalue: event.detail
        })
    },
    getShopKeeper() {
        let _this = this
        let data = {
            "limit": _this.data.limit,
            "page": _this.data.page,
            "goodsName": _this.data.Serchvalue
        }
        Api.shopkeeperApi(data).then(res => {
            if(res.code === 0) {
                let records = res.page.records
                let list = _this.data.list
                for (let i=0; i<records.length; i++) {
                    list.push(records[i])
                }
                _this.setData({
                    list: list
                })
            }
        })
    },
    refreshBottom() {
        let page = this.data.page
        page++
        this.setData({
            page: page
        })
        this.getShopKeeper()
    }
  
  

  







});
